#define _CRT_SECURE_NO_WARNINGS 1



//打印前40个斐波那契数
#include<stdio.h>
void PrintFib()
{
	
	int a = 1;
	int b = 1;
	int i = 0;
	for (i = 0; i < 20; i++)
	{
		if (i % 2 == 0)
		{
			printf("\n");
		}
		printf("%12d%12d", a, b);
		a = a + b;
		b = a + b;
	}
	
}
int main()
{
	PrintFib();
	return 0;
}



//找出二维数组中的最大值及其所对应的下标
#include<stdio.h>
int main()
{
	int arr[3][4] = { 1,2,3,4,9,8,7,6,-10,10,-5,2 };
	int i = 0;
	int max = 0;
	int row = 0;
	int col = 0;
	for (i = 0; i < 3; i++)
	{
		int j = 0;
		for (j = 0; j < 4; j++)
		{
			if (arr[i][j] > max)
			{
				max = arr[i][j];
				row = i;
				col = j;
			}
		}
	}
	printf("max = %d\nrow = %d\ncol = %d\n", max, row, col);
	return 0;
}



//求两个数的最大公约数和最小公倍数
#include<stdio.h>
int GCD(int a, int b)
{
	while (a%b!=0)
	{
		int tmp = 0;
		tmp = a;
		a = b;
		b = tmp % b;
	}
	return b;
}
int LCM(int a, int b, int gcd)
{
	return a * b / gcd;
}
int main()
{
	int a = 0;
	int b = 0;
	scanf("%d %d", &a, &b);
	int gcd = GCD(a,b);//最大公约数
	int lcm = LCM(a,b,gcd);//最小公倍数
	printf("gcd = %d\nlcm = %d\n", gcd, lcm);
	return 0;
}


//求π的近似值
#include<stdio.h>
#include<math.h>
int main()
{
	long i = 1;
	float pi = 0;
	while (i * i <= 10e+6)
	{
		pi = pi + 1.0 / (i * i);//注意必须为1.0
		i++;
	}
	pi = sqrt(6.0 * pi);//包含其头文件
	printf("pi = %f\n", pi);
	return 0;
}




//一元换1，2，5分

#include<stdio.h>
int main()
{
	int i = 0;//5分个数
	int j = 0;//2分个数
	int k = 0;//1分个数
	int l = 0;
	for (i = 0; i <= 20; i++)
	{
		for (j = 0; j <= 50; j++)
		{
			k = 100 - 5 * i - 2 * j;
			if (k>=0)
			{
				printf(" %2d %2d %2d ", i, j, k);
				l++;
				if (l % 5 == 0)
					printf("\n");
			}
			

		}
	}
	return 0;
}

